//
//  RepairCell.m
//  PropertyMananger
//
//  Created by bh on 16/12/22.
//  Copyright © 2016年 BH. All rights reserved.
//

#import "RepairCell.h"

@implementation RepairCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    
}

+(instancetype)cellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"RepairCellID";
    RepairCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if(cell == nil) {
        cell = [[RepairCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    //选中cell的颜色 -无色
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        static CGFloat bgViewH = 155;
        self.bgView = [[UIView alloc]init];
        [self.contentView addSubview:self.bgView];
      //  self.bgView.backgroundColor = [UIColor cyanColor];
        
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self.contentView).with.offset(0);
            make.top.equalTo(self.contentView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW, bgViewH));
        }];
        
        //摇一摇开门
        self.shakeBgView = [[UIView alloc]init];
        [self.bgView addSubview:self.shakeBgView];
        
   //     self.shakeBgView.backgroundColor = [UIColor cyanColor];
        [self.shakeBgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self.bgView).with.offset(0);
            make.top.equalTo(self.bgView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/2, bgViewH));
        }];
        UIView * shakeLine = [[UIView alloc]init];
        [self.bgView addSubview:shakeLine];
        shakeLine.backgroundColor = BHGrayColor;
        [shakeLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.bgView).with.offset(0);
            make.centerX.equalTo(self.bgView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(1, bgViewH));
        }];
        
        //shakeimage
        self.shakeImg = [[UIImageView alloc]init];
        [self.shakeBgView addSubview:self.shakeImg];
        self.shakeImg.image = [UIImage imageNamed:@"ico_home_shake"];
        [self.shakeImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.shakeBgView).with.offset(-30);
            make.centerX.equalTo(self.shakeBgView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(80, 60));
        }];
        //title
        self.shakeTieleLab = [[UILabel alloc]init];
        [self.shakeBgView addSubview:self.shakeTieleLab];
        self.shakeTieleLab.text = @"摇一摇开门";
        self.shakeTieleLab.textAlignment = NSTextAlignmentCenter;
        self.shakeTieleLab.font = [UIFont systemFontOfSize:15];
        self.shakeTieleLab.textColor = BHColor(26, 26, 26);
        
     //   self.shakeTieleLab.backgroundColor = [UIColor redColor];
        
        [self.shakeTieleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.shakeImg.mas_bottom).with.offset(5);
            make.centerX.equalTo(self.shakeBgView).offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/3, 30));
        }];
        
        //subtitle
        self.shakeSubTitleLab = [[UILabel alloc]init];
        [self.shakeBgView addSubview:self.shakeSubTitleLab];
        self.shakeSubTitleLab.text = @"手机摇一摇即可开门";
        self.shakeSubTitleLab.textAlignment = NSTextAlignmentCenter;
        self.shakeSubTitleLab.textColor= BHColor(152, 153, 153);
        self.shakeSubTitleLab.font = BHFont(12);
        
     //   self.shakeSubTitleLab.backgroundColor = BHRandColor;
        [self.shakeSubTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.shakeTieleLab.mas_bottom).with.offset(-5);
            make.centerX.equalTo(self.shakeBgView).offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/2, 30));
        }];
    
        //报修单
        self.repairBgView = [[UIView alloc]init];
        [self.bgView addSubview:self.repairBgView];
     
       
     //   self.repairBgView.backgroundColor = [UIColor orangeColor];
        [self.repairBgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.trailing.equalTo(self.bgView).with.offset(0);
            make.top.equalTo(self.bgView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/2, bgViewH/2));
        }];
        
        UIView * repairLine = [[UIView alloc]init];
        [self.bgView addSubview:repairLine];
        repairLine.backgroundColor = BHGrayColor;
        [repairLine mas_makeConstraints:^(MASConstraintMaker *make) {

            make.leading.equalTo(self.shakeBgView.mas_trailing).with.offset(0);
            make.top.equalTo(self.repairBgView.mas_bottom).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/2, 1));
        }];
        
        //保修数量
        self.repairCountLab = [[UILabel alloc]init];
        [self.repairBgView addSubview:self.repairCountLab];
        self.repairCountLab.text = @"6";
        self.repairCountLab.textAlignment = NSTextAlignmentCenter;
        self.repairCountLab.font = BHFont(15);
        self.repairCountLab.textColor = [UIColor redColor];
   //     self.repairCountLab.backgroundColor = BHRandColor;
        [self.repairCountLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.repairBgView).with.offset(0);
            make.centerX.equalTo(self.repairBgView).offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/3, 30));
        }];
        //title
        self.repairTitleLab = [[UILabel alloc]init];
        [self.repairBgView addSubview:self.repairTitleLab];
        self.repairTitleLab.textColor = BHColor(26, 26, 26);
        self.repairTitleLab.text = @"报修单";
        self.repairTitleLab.textAlignment = NSTextAlignmentCenter;
        self.repairTitleLab.font = BHFont(15);
        
        [self.repairTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.repairCountLab.mas_bottom).with.offset(0);
            make.centerX.equalTo(self.repairBgView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/3, 25));
        }];
        
        //subtitle
        self.repairSubtitleLab = [[UILabel alloc]init];
        [self.repairBgView addSubview:self.repairSubtitleLab];
        self.repairSubtitleLab.text = @"未处理";
        self.repairSubtitleLab.textAlignment = NSTextAlignmentCenter;
        self.repairSubtitleLab.font = BHFont(12);
        self.repairSubtitleLab.textColor = BHColor(153, 153, 153);
        
        [self.repairSubtitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.repairTitleLab.mas_bottom).with.offset(-5);
            make.centerX.equalTo(self.repairBgView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/3, 25));
        }];

        
        //投诉单
        self.complainBgView = [[UIView alloc]init];
        [self.bgView addSubview:self.complainBgView];
        
     //   self.complainBgView.backgroundColor = [UIColor cyanColor];
        [self.complainBgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self.shakeBgView.mas_trailing).with.offset(0);
            make.top.equalTo(self.repairBgView.mas_bottom).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/4, bgViewH/2));
        }];
        
        UIView * complainLine = [[UIView alloc]init];
        [self.bgView addSubview:complainLine];
        complainLine.backgroundColor = BHGrayColor;
        [complainLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self.complainBgView.mas_trailing).with.offset(0);
            make.top.equalTo(self.repairBgView.mas_bottom).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(1, bgViewH/2));
        }];
        
        //
        self.complainCountLab = [[UILabel alloc]init];
        [self.complainBgView addSubview:self.complainCountLab];
        self.complainCountLab.text = @"3";
        self.complainCountLab.textAlignment = NSTextAlignmentCenter;
        self.complainCountLab.textColor = [UIColor redColor];
        self.complainCountLab.font = BHFont(15);
        
        [self.complainCountLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.complainBgView).with.offset(0);
            make.centerX.equalTo(self.complainBgView).offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/3, 30));
        }];
        
        self.complainLab = [[UILabel alloc]init];
        [self.complainBgView addSubview:self.complainLab];
        self.complainLab.text = @"投诉单";
        self.complainLab.textColor = BHColor(26, 26, 26);
        self.complainLab.textAlignment = NSTextAlignmentCenter;
        self.complainLab.font = BHFont(15);
        
        [self.complainLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.complainCountLab.mas_bottom).with.offset(0);
            make.centerX.equalTo(self.complainBgView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/3, 25));
        }];
        
        self.complainSubtitleLab = [[UILabel alloc]init];
        [self.complainBgView addSubview:self.complainSubtitleLab];
        self.complainSubtitleLab.text = @"未处理";
        self.complainSubtitleLab.textAlignment = NSTextAlignmentCenter;
        self.complainSubtitleLab.font = BHFont(12);
        self.complainSubtitleLab.textColor = BHColor(153, 153, 153);
        
        [self.complainSubtitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.complainLab.mas_bottom).with.offset(-5);
            make.centerX.equalTo(self.complainBgView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/3, 25));
        }];
        
        //消息
        self.messageBgView = [[UIView alloc]init];
        [self.bgView addSubview:self.messageBgView];

        //    self.messageBgView.backgroundColor = [UIColor purpleColor];
        [self.messageBgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.trailing.equalTo(self.bgView).with.offset(0);
            make.top.equalTo(self.complainBgView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/4, bgViewH/2));
        }];
        
        self.messageCountLab = [[UILabel alloc]init];
        [self.messageBgView addSubview:self.messageCountLab];
        self.messageCountLab.text = @"3";
        self.messageCountLab.textAlignment = NSTextAlignmentCenter;
        self.messageCountLab.textColor = [UIColor redColor];
        self.messageCountLab.font = BHFont(15);
        
        [self.messageCountLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.messageBgView).with.offset(0);
            make.centerX.equalTo(self.messageBgView).offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/3, 30));
        }];
        
        self.messageLab = [[UILabel alloc]init];
        [self.messageBgView addSubview:self.messageLab];
        self.messageLab.text = @"消息";
        self.messageLab.textColor = BHColor(26, 26, 26);
        self.messageLab.textAlignment = NSTextAlignmentCenter;
        self.messageLab.font = BHFont(15);
        
        [self.messageLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.messageCountLab.mas_bottom).with.offset(0);
            make.centerX.equalTo(self.messageBgView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/3, 25));
        }];
        
        self.messageSubtitleLab = [[UILabel alloc]init];
        [self.messageBgView addSubview:self.messageSubtitleLab];
        self.messageSubtitleLab.text = @"未读消息";
        self.messageSubtitleLab.textAlignment = NSTextAlignmentCenter;
        self.messageSubtitleLab.font = BHFont(12);
        self.messageSubtitleLab.textColor = BHColor(153, 153, 153);
        
        [self.messageSubtitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.messageLab.mas_bottom).with.offset(-5);
            make.centerX.equalTo(self.messageBgView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/3, 25));
        }];
        
            //添加手势
        //    UITapGestureRecognizer * shakeTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(shakeAction:)];
            self.shakeBgView.userInteractionEnabled = YES;
       //     [self.shakeBgView addGestureRecognizer:shakeTap];

       // UITapGestureRecognizer * repairTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(repairAction:)];
        self.repairBgView.userInteractionEnabled = YES;
     //   [self.repairBgView addGestureRecognizer:repairTap];
        
    //    UITapGestureRecognizer * complaintTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(complaintAction:)];
         self.complainBgView.userInteractionEnabled = YES;
     //   [self.complainBgView addGestureRecognizer:complaintTap];
        
     //   UITapGestureRecognizer * messageTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(messageAction:)];
        self.messageBgView.userInteractionEnabled = YES;
   //     [self.messageBgView addGestureRecognizer:messageTap];

    }
    return self;
}
- (void)shakeAction:(UITapGestureRecognizer *)tap
{
         DLog(@"点击摇一摇");
}
- (void)repairAction:(UITapGestureRecognizer *)tap
{
       DLog(@"点击报修单");
    
}
- (void)complaintAction:(UITapGestureRecognizer *)tap
{
       DLog(@"点击投诉单");
}
- (void)messageAction:(UITapGestureRecognizer *)tap
{
       DLog(@"点击消息");
}
@end
